<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <!-- <link rel="stylesheet" type="text/css" href="../css/menu.css" /> -->
    <link rel="stylesheet" type="text/css" href="../css/mzui/css/mzui.min.css" />
    <style>
     th{
            text-align: center;
        }
        td{
            text-align: center;
        }
       .infoTop{
	background-color:#d65b5d;
	height:73px;
	/* border-bottom:1px solid #994c00; */
	text-align:center;
	/* border:1px solid red; */	
}
.infoTop a{
	position:absolute;
	height:37px;
	padding:34px 20px 0 20px;
	top:0px;
	left:0px;
	cursor:pointer;	
}
.infoTop img{
	height:25px;
	
}
.infoTop span{
	position:absolute;
	top:24px;
	left:150px;
	font-size:20px;
	height:50px;
	line-height:50px;
	color:#fff;
	cursor:default;	
}
.infoTop .nav{
	float:left;
	width:25px;
	height:25px;
	margin:35px 15px auto 20px;
}
.infoTop .moretype{
	position:absolute;
	top:29px;
	right:15px;
	height:40px;
	width:40px;
	line-height:40px;
	color:#fff;
	cursor:pointer;
	background:url() no-repeat right 10px;
	/*background:url() no-repeat right 10px;*/
	background-size:20px 20px;
}
.save-btn{
	position:fixed;
	bottom:0px;
	padding-left:59px;
	padding-right:59px;	
    height:56px;
    width:100%;
    background-color: #FFFFFF;
    display: block;
}
.save-btn #svBtn{
 	display:inline-block;
	height:35px;
	width:242px;
	margin-top:12px;
	border:none;
	background-color:#D65B5D;
	border-radius:10px;
	outline:none;
	color:#fff;
	font-size:16px;
	font-family:"方正兰亭黑简体","Microsoft YaHei";
	line-height:16px;
	text-align:center;
	cursor:pointer;
	text-decoration:none;
} 
.save-btn #svBtn:hover{
	background-color:#d65b5d;
}
.save-btn #svBtn:active{
	background-color:#FFAEB9;
} 
    </style>
</head>
<body>
   
	<div class="page">
	    
	    <div class="infoTop">
	        <!--<img class="nav" id="openMenu" src=""/>
			--> <a onClick="javascript :api.closeWin();"><img alt="返回" src="" title="back"></a>  
			<span>试块修改</span>
			<!-- <div class="moretype" onclick="showscanner()"> </div> -->
		</div>
       <div class="save-btn" id="save-btn">
	        <button type="button" id="svBtn" >确认</button>
	   </div>  
    </div>
	      
</body>
<script type="text/javascript" src="../script/public/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/core/core.js"></script>
<!--<script type="text/javascript" src="../script/mzui/js/mzui.min.js"></script>-->
<script type="text/javascript">
	apiready = function(){
        var objId=api.pageParam.objId;
	
    
	 api.openFrame({
	    name: 'frm_updateBlock',
	    url: 'frm_updateBlock.html',
	    reload:true,
	    pageParam: {
	        objId:objId,
	        
	       },
	    rect: {
		    x:0,
		    y:74,
		    w: api.winWidth,
	        h: api.winHeight-130
	    }
    });
//	//右滑打开菜单
//		api.addEventListener({
//		    name:'swiperight'
//		}, function(ret, err){        
//		   api.openFrame({
//	           name: 'leftMenu',
//	           url: 'left_menu.html',
//	           rect: {
//		           x:0,
//		           y:0,
//		           w:api.winWidth/2,
//		           h:api.winHeight
//	           }
//         });
//		});
//		
	//测试--不能触屏
	
	$("#openMenu").click(function(){	
		 api.openFrame({
		           name: 'leftMenu',
		           url: 'left_menu.html',
		           rect: {
			           x:0,
			           y:0,
			           w:api.winWidth/2,
			           h:api.winHeight
		           }
		      });
	    });
	    
	    
	    
//	    setListenerAjpush();
//	    setNotice();
	};
	
	
	//点击确认
$("#svBtn").click(function(){
    api.execScript({
	    frameName: 'frm_updateBlock',
		script: 'saveMaterial();'
	});
});	  
 function exitApp(){
            api.addEventListener({
                name: 'keyback'
            }, function(ret, err){
                api.toast({
                        msg: '再按一次返回键退出'+api.appName,
                        duration:2000,
                        location: 'bottom'
                    });
                   
                    api.addEventListener({
                        name: 'keyback'
                    }, function(ret, err){
                        api.closeWidget({
                                id: 'A6057658489882',     //这里改成自己的应用ID
                                retData: {name:'closeWidget'},
                                silent:true
                            });
                    });
                   
                    setTimeout(function(){
                            exitApp();
                    },3000)
            });
    }
    
    function showscanner(){
   var role=$api.getStorage("user").role;
   //alert(role);
   var FNScanner = api.require('FNScanner');
	FNScanner.openScanner(function(ret, err) {
		//alert(JSON.stringify(ret));
	    if (ret.eventType=='success') {
	      	var scanId=ret.content;
	      	//alert(scanId);
	        //api.open
	        ajaxLocal({scanId:scanId},'Scan','checkScan',function(ret,err){
	           //alert(JSON.stringify(ret));
	           if(ret.success){
	             //alert("有信息！");
	             if(ret.flag){//计划单
	             	if(role=='库管员'){//库管员
						//alert(role);
						api.openWin({
		                    name: 'win_confirmSend',
		                    url: 'win_confirmSend.html',
		                    reload:true,
		                    pageParam:{
					         scanId:scanId
					        },
		                    rect: {
				                x: 0,
				                y: 0,
				                w: 'auto',
				                h: 'auto'
				            }
		                });
								
					}else if(role=='现场工人'){//现场工人
					 //alert(role);
					 api.openWin({
		                    name: 'win_confirmRec',
		                    url: 'win_confirmRec.html',
		                    reload:true,
		                    pageParam:{
					         planId:"",
					         scanId:scanId
					        },
		                    rect: {
				                x: 0,
				                y: 0,
				                w: 'auto',
				                h: 'auto'
				            }
		                });	
					}
	             }else{
	              	//alert("调拨单！");
	             	if(role=='库管员'){//库管员
						//alert(role);
						api.openWin({
		                    name: 'win_confirmAllocate',
		                    url: 'win_confirmAllocate.html',
		                    reload:true,
		                    pageParam:{
					         scanId:scanId
					        },
		                    rect: {
				                x: 0,
				                y: 0,
				                w: 'auto',
				                h: 'auto'
				            }
		                });
								
					}else if(role=='现场工人'){//现场工人
					// alert(role);
					 api.openWin({
		                    name: 'win_confirmRecAllo',
		                    url: 'win_confirmRecAllo.html',
		                    reload:true,
		                    pageParam:{
					         planId:"",
					         scanId:scanId
					        },
		                    rect: {
				                x: 0,
				                y: 0,
				                w: 'auto',
				                h: 'auto'
				            }
		                });	
					}
	             }
	           }else{
	             alert(ret.message);
	           }
	        
	        });
//      	if(role.length==3){//库管员
//				//alert(role);
//				api.openWin({
//                  name: 'win_confirmSend',
//                  url: 'win_confirmSend.html',
//                  reload:true,
//                  pageParam:{
//			         scanId:scanId
//			        },
//                  rect: {
//		                x: 0,
//		                y: 0,
//		                w: 'auto',
//		                h: 'auto'
//		            }
//              });
//						
//			}else{//现场工人
//			 //alert(role);
//			 api.openWin({
//                  name: 'win_confirmRec',
//                  url: 'win_confirmRec.html',
//                  reload:true,
//                  pageParam:{
//			         planId:"",
//			         scanId:scanId
//			        },
//                  rect: {
//		                x: 0,
//		                y: 0,
//		                w: 'auto',
//		                h: 'auto'
//		            }
//              });	
//			}	
				      	
	  }
		      
    });	
//	if(role.length==3){//库管员
//		alert(role);		
//	}else{
//		alert(role);
	//}	
}
 function setTagsName(){
       
			var role=$api.getStorage("user").role;
			//var shopId = kitChen.shopsAccountEntity.objId;
			//var unit=api.pageParam.unit;
			//alert("智能体：--分组"+role)
			var ajpush = api.require('ajpush');
			var param = {tags:[role]};
			ajpush.bindAliasAndTags(param,function(ret) {
			        var statusCode = ret.statusCode;
			        //alert(JSON.stringify(ret));
			});
		}
    
  function setListenerAjpush() {
		//alert("监听");
			var ajpush = api.require('ajpush');
			ajpush.setListener(function(ret) {
			//alert("不坑爹");
				api.startPlay({
                        path : 'widget://res/1.mp3'
                }, function() {
                        api.startRecord();
                });
				var content = ret.content;
				//alert("监听内容"+content);
				var id=content.substring(0,content.indexOf('_'));
//				//alert("监听内容id"+id);
				var type=content.substring(content.indexOf('_')+1,content.length);//仓库
//				//alert("监听内容type"+type);
				if(type=='0'){//配送计划
					api.openFrame({
					    name: 'frm_getPushInfo',
					    url: 'frm_getPushInfo.html',
					    reload:true,
					     pageParam:{
			         		 id:id,		
					         type:type
					         
					        },
					    rect: {
						    x:0,
						    y:0,
						    w: 'auto',
							h: 'auto'
				    }
			    });	
				}else{//领料单
				api.openFrame({
				    name: 'frm_getPushInfoPicking',
				    url: 'frm_getPushInfoPicking.html',
				    reload:true, 
				     pageParam:{
		         		 id:id,		
				         type:type
				         
				        },
				    rect: {
					    x:0,
					    y:0,
					    w: 'auto',
						h: 'auto'
				    }
			    });	
			}
		});
	}  
  	function setNotice() {
		//alert("等通知");
			api.addEventListener({
			    name: 'appintent'
			}, function(ret, err) {
			    if (ret && ret.appParam.ajpush) {
			        var ajpush = ret.appParam.ajpush;
			        var content = ajpush.content;
			      // alert("点通知内容"+content);
			        var id=content.substring(0,content.indexOf('_'));
//			        //alert("点通知内容id"+id);
					var type=content.substring(content.indexOf('_')+1,content.length);//仓库
//					//alert("点通知内容type"+type);
								if(type=='0'){//配送计划
					api.openFrame({
					    name: 'frm_getPushInfo',
					    url: 'frm_getPushInfo.html',
					    reload:true,
					     pageParam:{
			         		 id:id,		
					         type:type
					         
					        },
					    rect: {
						    x:0,
						    y:0,
						    w: 'auto',
							h: 'auto'
				    }
			    });	
				}else{//领料单
				api.openFrame({
				    name: 'frm_getPushInfoPicking',
				    url: 'frm_getPushInfoPicking.html',
				    reload:true, 
				     pageParam:{
		         		 id:id,		
				         type:type
				         
				        },
				    rect: {
					    x:0,
					    y:0,
					    w: 'auto',
						h: 'auto'
				    }
			    });	
			}

			    }
			});
		}  
</script>
</html>